package com.javaee.xiangyang.util;

import com.javaee.xiangyang.entity.enmu.BaseStateEnum;

public class CodeEnumUtil {
    public static <T extends Enum<?> & BaseStateEnum> T codeOf(Class<T> enumClass, int code){
        T[] enumConstants = enumClass.getEnumConstants();
        for (T t : enumConstants){
            if (t.getCode() == code){
                return t;
            }
        }
        return null;
    }
}
